package com.vicene.gmail.order.vo;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
public class OrderConfirmVo {
    //收货地址
    @Getter @Setter
    List<MemberAddressVo> address;

    //选中的购物项
    @Getter @Setter
    List<OrderItemVo> items;

    //TODO 发票记录

    //优惠券
    @Getter @Setter
    Integer integration;

   //BigDecimal total;
    //应付价格
    //BigDecimal payPrice;
    //防重令牌
    @Getter @Setter
    String orderToken;

    @Getter @Setter
    Map<Long, Boolean> stocks;

    public BigDecimal getTotal(){
        BigDecimal sum  = new BigDecimal(0);
        if(!CollUtil.isEmpty(items)){
            for(OrderItemVo item : items){
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()) );
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    public BigDecimal getPayPrice(){
        return getTotal();
    }
}
